Crate android_logger[−][src]
A logger which writes to android output.
Example
#[macro_use] extern crate log; extern crate android_logger; use log::Level; use android_logger::Config; /// Android code may not have obvious "main", this is just an example. fn main() { android_logger::init_once( Config::default().with_min_level(Level::Trace), ); debug!("this is a debug {}", "message"); error!("this is printed by default"); }
Example with module path filter
It is possible to limit log messages to output from a specific crate, and override the logcat tag name (by default, the crate name is used):
#[macro_use] extern crate log; extern crate android_logger; use log::Level; use android_logger::{Config,FilterBuilder}; fn main() { android_logger::init_once( Config::default() .with_min_level(Level::Trace) .with_tag("mytag") .with_filter(FilterBuilder::new().parse("debug,hello::crate=trace").build()), ); // .. }
Example with a custom log formatter
use android_logger::Config; android_logger::init_once( Config::default() .with_min_level(log::Level::Trace) .format(|f, record| write!(f, "my_app: {}", record.args())) )
Structs
AndroidLogger | Underlying android logger backend |
Config | Filter for android logger. |
Filter | A log filter. |
FilterBuilder | A builder for a log filter. |
Formatter | A formatter to write logs into. |
Functions
init_once | Initializes the global logger with an android logger. |
log | Send a log record to Android logging backend. |